#!/bin/bash

## 安装bind
yum -y install bind-utils bind bind-devel bind-libs

## 修改配置文件
eFname="named.conf"
forwardIps="202.96.128.166;8.8.8.8;"
sed -e '/listen-on port 53/s/127.0.0.1/any/' ${eFname}
sed -e '/allow-query/s/localhost/any/' ${eFname}

num=$(grep -n 'forwarders' ${eFname} | awk -F':' '{print $1}')
if [[ ${num} == "" ]]; then
    sed -e "/session-keyfile/a\        forwarders { ${forwardIps} };" ${eFname}
fi

## 添加服务并启动
systemctl start named
systemctl enable named

